<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DOM</title>
</head>

<body>
    <div><input type="checkbox" id="agree">同意并接受注册协议</div>
    <button>提交</button>
</body>
<script>
    let btn = document.querySelector('button');
    btn.onclick = function () {
        if (document.getElementById('agree').checked) {
            alert("提交成功");
        } else {
            alert("不同意协议，我们将无法为您提供服务");
        }
    }
</script>

</html>